<?php
include "../header.inc";
require_once "../DataBase.inc";
require_once "../DB/database.inc";

if (isset($_POST["applicant_id"]) || isset($_GET["applicant_id"])) {
	if (isset($_POST["applicant_id"]))
		$id = $_POST["applicant_id"];
	else
		$id = $_GET["applicant_id"];
	global $app_fields;
	foreach ($app_fields as $table=>$fields) {
		if (array_key_exists("applicant_id",$fields))
			DataBase::delete($table, array("applicant_id"=>$id));
	}
	echo "Applicant removed from the database.<br/>";
	echo "<a href='../applicants.php?view=general'>See the list of applicants</a><br/>";
	die();
}

$id = $_GET["id"];
$applicant = DataBase::query("SELECT * FROM applicant WHERE applicant_id=".$id);
if ($applicant == false || count($applicant)==0) die("Invalid ID");
$applicant = $applicant[0];
?>
Your are going to remove the applicant <b><?php echo $applicant["applicant_firstname"]." ".$applicant["applicant_lastname"]?></b>.<br/>
The applicant will be completely removed from the database and this cannot be undone!<br/>
Are you sure you want to do that ?<br/>
<form method="post">
<input type='hidden' name='applicant_id' value='<?php echo $id?>'/>
<button type="submit">Yes I am sure</button><br/>
</form>

